﻿@{
    ViewData["Title"] = "工作事项";
}

<div class="panel panel-default">
    <div class="form-content">
        <div class="form-body">
            <div class="row" id="filter" data-toggle="form" data-field="Item" data-grid="#grid" data-filterable="true">
                <input data-field="Name,Code,Assign.Name" data-size="4,0,12" data-logic="or" data-operator="contains" />
                <button data-button="query">查询</button>
                <button data-button="clear">清除条件</button>
                <div class="pull-right" style="padding-right:15px;">
                    <button data-button="add" data-popup="ItemEdit">新 增</button>
                </div>
            </div>
            <div id="grid" data-toggle="grid" data-form="#filter" node="grid" data-related="#_PopupItemDetail">
                <div node="columns" node-type="array">
                    <span data-field="Name" data-title="工作事项名称"></span>
                    <span data-field="Code" data-title="工作事项编号"></span>
                    <span data-field="ItemType" data-title="工作事项类型" data-template="#:data=>$.com.commonFormatter(cache.itemTypes, data.ItemType)"></span>
                    <span data-field="ItemState" data-title="工作事项状态" data-template="#:data=>$.com.commonFormatter(cache.itemStates, data.ItemState)"></span>
                    <span data-field="Assign.Name" data-title="分配到"></span>
                    <span data-field="Description" data-title="备注说明"></span>
                    <span data-field="CreatedOn" data-title="创建时间" data-type="date"></span>
                </div>
                <span node="dataSource">
                    <span node="transport">
                        <span node="read" data-url="/odata/Items?$expand=Assign($select=Id,Name)">
                        </span>
                    </span>
                </span>
            </div>
        </div>
    </div>
</div>

<div id="_PopupItemDetail" data-toggle="popup" data-type="ItemDetail" data-title="工作事项" data-size="large">
    <div class="popup-content" data-toggle="form" data-field="Item" data-detailable="true" data-size="6,4,8">
        <div class="popup-body">
            <div class="form-content">
                <div class="form-heading">
                    <span>工作事项信息</span>
                </div>
                <div class="form-body">
                    <span data-field="Name" data-label="工作事项名称"></span>
                    <span data-field="Code" data-label="工作事项编号"></span>
                    <span data-field="ItemType" data-label="工作事项类型" data-formatter="#:el=>$.com.commonFormatter(cache.itemTypes, el.options.value)"></span>
                    <span data-field="ItemState" data-label="工作事项状态" data-formatter="#:el=>$.com.commonFormatter(cache.itemStates, el.options.value)"></span>
                    <span data-field="Assign.Name" data-label="分配到"></span>

                    <div class="row">
                        <span data-field="Description" data-label="备注说明" data-size="12,2,8"></span>
                    </div>
                </div>
            </div>
            @await Html.PartialAsync("../Template/Additional/_List", new ItemAdditional { Key = "cache.itemAdditionalType" })
        </div>
        <div class="popup-footer text-right">
            <button data-button="edit" data-popup="ItemEdit">编 辑</button>
            <button data-button="close">关 闭</button>
        </div>
    </div>
</div>

<div id="_PopupItemEdit" data-toggle="popup" data-type="ItemEdit" data-title="工作事项" data-related="#filter" data-size="large">
    <div class="popup-content" data-toggle="form" data-field="Item" data-editable="true" data-url="/odata/Items">
        <div class="popup-body">
            <div class="form-content">
                <div class="form-heading">
                    <span>工作事项信息</span>
                </div>
                <div class="form-body">
                    <input data-field="Name" data-label="工作事项名称" required />
                    <input data-field="Code" data-label="工作事项编号" required />
                    <span data-field="ItemType" data-label="工作事项类型" type="radio" data-with-group="true" data-data="#:cache.itemTypes" data-value="Task"></span>
                    <span data-field="ItemState" data-label="工作事项状态" type="radio" data-with-group="true" data-data="#:cache.itemStates" data-value="Pending"></span>
                    <select data-field="AssignId" data-label="分配到" data-role="kendoDropDownList" data-side="server" data-url="/api/Users" data-data-value-field="Id" data-data-text-field="Name"></select>
                    <textarea data-field="Description" data-label="备注说明" rows="5" data-multiple="true"></textarea>
                </div>
            </div>
            @await Html.PartialAsync("../Template/Additional/_Edit", new ItemAdditional {  Key = "cache.itemAdditionalType" })
        </div>
        <div class="popup-footer text-right">
            <button data-button="post" data-success-text="新增成功">新 增</button>
            <button data-button="put" data-success-text="保存成功">提 交</button>
            <button data-button="delete" data-success-text="删除成功">删 除</button>
            <button data-button="close">关 闭</button>
        </div>
    </div>
</div>

@*<div node="template">
    <div id="_TemplateItemAdditionalDetail">
    <div class="form-content" data-toggle="form" data-field="ItemAdditional">
    <div class="form-heading">
    </div>
    <div class="form-body">
    <div class="row">
    <div class="col-md-6">
    <span data-field="Key" data-label="类别" data-size="12,4,8" data-formatter="#:el=>$.com.commonFormatter(cache.itemAdditionalType, el.options.value)"></span>
    </div>
    <div class="col-md-6">
    <span data-field="Index" data-label="序号" data-size="12,4,8"></span>
    </div>
    <span data-field="Value" data-label="内容" data-size="12,2,9"></span>
    </div>
    </div>
    </div>
    </div>

    <div id="_TemplateItemAdditionalEdit">
    <div class="form-content" data-toggle="form" data-field="ItemAdditional">
    <div class="form-heading">
    </div>
    <div class="form-body">
    <span class="floatRightButton" data-button="removeForm"></span>
    <div class="row">
    <div class="col-md-6">
    <input data-field="Key" data-label="类别" required data-role="kendoDropDownList" data-size="12,4,8" data-data-source="#:cache.itemAdditionalType" />
    </div>
    <div class="col-md-5">
    <input data-field="Index" data-label="序号" required data-role="kendoNumericTextBox" data-min="1" data-max="999" data-format="d" data-size="12,4,8" />
    </div>
    </div>
    <div class="row">
    <input data-field="Value" data-label="内容" required data-size="12,2,9" />
    </div>
    </div>
    </div>
    </div>
    </div>*@